<?php

/**
 * Description of wrapper
 *
 * @author laimis
 */
class PhotoWrapper {

     public function wraperController(){
        $actionObject = $this->getRequestAction();
        if($actionObject != null){
            switch ($actionObject) {
                case 'add':
                    include_once BASEURL.'action/photo/add/wrapper.php';
                    new PhotoAddWrapper();
                    break;
                case 'edit':
                    $this->getRequestValues();
                    include_once BASEURL.'action/photo/edit.php';
                    new EditPhoto();
                    break;
                case 'delete':
                    $this->getRequestValues();
                    include_once BASEURL.'action/photo/delete.php';
                    new DeletePhoto();
                    break;
                case 'view':
                    include_once BASEURL.'action/photo/view.php';
                    new PhotoView();
                    break;
                default:
                    include_once BASEURL.'web/error.php';
                    exit ();
                    break;
            }
        }else{
            include_once BASEURL.'web/error.php';
            exit ();
        }
    }

    public function getRequestValues(){
        $result = '';
        if(isset ($_GET['route'])){
            $strings = explode( '/',$_GET['route']);
            $result = $strings[0];
            $request['object'] = $strings[0];
            $request['action'] = $strings[1];
            $request['arg'] = $strings[3];
            $_REQUEST['request'] = $request;
        }
        return $result;
    }

    public function getRequestAction(){
        $result = '';
        if(isset ($_REQUEST['request']['action'])){
            $result = $_REQUEST['request']['action'];
        }
        return $result;
    }

    public function PhotoWrapper(){
        $this->wraperController();
    }
}
?>
